#!/bin/bash
### BEGIN INIT INFO
# Provides:          exciter.sh
# Required-Start:    $fpga.sh
# Required-Stop:
# Default-Start:     S
# Default-Stop:
### END INIT INFO
#Define all nodes:

major=227
nodes=("TranslationMode" "ModulationSource" "StreamSource" "CdrReset" "S0DescribeModulationMode" "S0ServiceModulationMode" "S0SpectrumMode" "S0SubFrameAllocMode" "S0HighProtectedLDPC" "S0LowProtectedLDPC" "S0Hierarchical" "S1DescribeModulationMode" "S1ServiceModulationMode" "S1SpectrumMode" "S1SubFrameAllocMode" "S1HighProtectedLDPC" "S1LowProtectedLDPC" "S1Hierarchical" "S2DescribeModulationMode" "S2ServiceModulationMode" "S2SpectrumMode" "S2SubFrameAllocMode" "S2HighProtectedLDPC" "S2LowProtectedLDPC" "S2Hierarchical" "S3DescribeModulationMode" "S3ServiceModulationMode" "S3SpectrumMode" "S3SubFrameAllocMode" "S3HighProtectedLDPC" "S3LowProtectedLDPC" "S3Hierarchical" "FMAudioSource" "FMPreEmphasisCoefficient" "FMModulationMode" "FMFlagReadOnly" "FrequencyIdentified" "ExciterIdentification" "ExciterPID" "FMExtraDelay" "FM19KHzPilotPhase" "FMMainDelay" "FMLeftChannelVolume" "FMRightChannelVolume" "FMPilotVolume" "FMVolumeAdjustCoefficient" "FMModulationDegree" "GlCdrSfBegin" "GlOfdmDen" "GlMainFreq" "GlSrcSel" "GlRandMod" "GlSdrTlen" "GlFftExp" "GlChnSel" "GlScale" "GlTatt" "GlDprstB" "GlFhopChCtl" "GlTxEnable" "GlWaitForData" "GlForceWin" "GlCdrSfSel" "GlFspIdx" "GlCompleDate" "GlCdrSfFinish"
"TranslationModeStr" "ModulationSourceStr" "StreamSourceStr" "CdrResetStr" "S0DescribeModulationModeStr" "S0ServiceModulationModeStr" "S0SpectrumModeStr" "S0SubFrameAllocModeStr" "S0HighProtectedLDPCStr" "SOLowProtectedLDPCStr" "S0HierarchicalStr" "S1DescribeModulationModeStr" "S1ServiceModulationModeStr" "S1SpectrumModeStr" "S1SubFrameAllocModeStr" "S1HighProtectedLDPCStr" "S1LowProtectedLDPCStr" "S1HierarchicalStr" "S2DescribeModulationModeStr" "S2ServiceModulationModeStr" "S2SpectrumModeStr" "S2SubFrameAllocModeStr" "S2HighProtectedLDPCStr" "S2LowProtectedLDPCStr" "S2HierarchicalStr" "S3DescribeModulationModeStr" "S3ServiceModulationModeStr" "S3SpectrumModeStr" "S3SubFrameAllocModeStr" "S3HighProtectedLDPCStr" "S3LowProtectedLDPCStr" "S3HierarchicalStr" "FMAudioSourceStr" "FMPreEmphasisCoefficientStr" "FMModulationModeStr" "FMFlagReadOnlyStr" "FrequencyIdentifiedStr" "ExciterIdentificationStr" "ExciterPIDStr" "FMExtraDelayStr" "FM19KHzPilotPhaseStr" "FMMainDelayStr" "FMLeftChannelVolumeStr" "FMRightChannelVolumeStr" "FMPilotVolumeStr" "FMVolumeAdjustCoefficientStr" "FMModulationDegreeStr" "GlCdrSfBeginStr" "GlOfdmDenStr" "GlMainFreqStr" "GlSrcSelStr" "GlRandModStr" "GlSdrTlenStr" "GlFftExpStr" "GlChnSelStr" "GlScaleStr" "GlTattStr" "GlDprstBStr" "GlFhopChCtlStr" "GlTxEnableStr" "GlWaitForDataStr" "GlForceWinStr" "GlCdrSfSelStr" "GlFspIdxStr" "GlCompleDateStr" "GlCdrSfFinishStr")

load() {
    #载入Lcd驱动模块
    rmmod cdr_exciter.ko
    insmod /home/root/cdr_exciter.ko major="${major}"

    i=0
    for node in ${nodes[@]}; do
    nodePath=/dev/fpga$node
    #删除已存在的节点
    rm -f $nodePath
    #创建节点
    mknod $nodePath c $major $i
    echo mknod $nodePath c $major $i
    chmod 666 $nodePath
    ((i+=1))
    done
}

case "$1" in
  start)
    load
    ;;
  stop)
    ;;
  *)
    echo "Usage: cdrexciter {start|stop}"
    exit 1
esac

exit 0
